
<include file="Public/min-header"/>
<div class="wrapper">
	<include file="Public/breadcrumb"/>
	<section class="content">
		<div class="row">
			<div class="col-xs-12">
				<div class="box">
					<div class="box-header">
						<nav class="navbar navbar-default">
							<div class="collapse navbar-collapse">
								<div class="navbar-form row">
									<!--<div class="col-md-1">-->
									<!--<button class="btn bg-navy" type="button" onclick="tree_open(this);"><i class="fa fa-angle-double-down"></i>展开</button>-->
									<!--</div>-->
									<!--<div class="col-md-9">-->
									<!--<span class="warning">温馨提示：顶级分类（一级大类）设为推荐时才会在首页楼层中显示</span>-->
									<!--</div>-->
									<form action="{:U('Coach/categorySave')}" method="post">
										<input name="id" id="id" type="hidden" value="{$info.id}">
                                    
										<div>
											<div style="width:auto; float:left; margin-right:10px;">
												名称： <input  class="form-control" type="text" name="cate_name" value="{$info.name}" id="cate_name" >
											</div>
											<div style="width:auto; float:left; margin-right:10px;">
												图片：
												<input type="button" value="上传图片"  onclick="GetUploadify(1,'','goods','call_back');"/>
												<input type="text" class="input-sm"  name="original_img" id="original_img" value="{$info.original_img}"/>
												<if condition="$info['original_img'] neq null">
													&nbsp;&nbsp;
													<a target="_blank" href="{$info.original_img}" id="original_img2">
														<img width="25" height="25" src="/Public/images/image_icon.jpg">
													</a>
												</if>
												<!--<input  class="form-control" type="text" name="cate_name" id="cate_name" >-->
											</div>
											<div style="width:auto; float:left; margin-right:10px;">
												<input type="submit" name="submit" class="btn btn-primary pull-right" value="<if condition='$info[id] gt 0'>提交修改<else/>添加分类</if> " >
												<!--<a href="{:U('Coach/categoryAdd')}" class="btn btn-primary pull-right"><i class="fa fa-plus"></i>新增</a>-->
											</div>
										</div>

									</form>

								</div>
							</div>
						</nav>
					</div><!-- /.box-header -->
					<div class="box-body">
						<div class="row">
							<div class="col-sm-12">
								<table id="list-table" class="table table-bordered table-striped dataTable" role="grid" aria-describedby="example1_info">
									<thead>
									<tr role="row">
										<th valign="middle">分类ID</th>
										<th valign="middle">分类名称</th>
										<th valign="middle">图片</th>
										<th valign="middle">操作</th>
									</tr>
									</thead>
									<tbody>
									<foreach name="cat_list" item="vo" key="k" >
										<tr role="row" align="center" class="{$vo.level}" id="{$vo.level}_{$vo.id}" <if condition="$vo[level] gt 1">style="display:none"</if>>
										<td>{$vo.id}</td>
										<td align="left" style="padding-left:<?php echo ($vo[level] * 5); ?>em">

											<span>{$vo.name} </span>
										</td>
										<td align="left" style="padding-left:<?php echo ($vo[level] * 5); ?>em">

										<img  src="{$vo.original_img}" style="height:50px;"/>
										</td>


										<td>
											<a class="btn btn-primary" href="{:U('categoryList',array('id'=>$vo['id']))}">修改</a>
											<a class="btn btn-danger" href="javascript:del_fun('{:U('Coach/categoryDelete',array('id'=>$vo['id']))}');">删除</a>
										</td>
										</tr>
									</foreach>
									</tbody>
								</table></div></div>

					</div><!-- /.box-body -->
				</div><!-- /.box -->
			</div>
		</div>
	</section>
</div>
<script type="text/javascript">

    function call_back(fileurl_tmp){



        $("#original_img").val(fileurl_tmp);
        $("#original_img2").attr('href', fileurl_tmp);
    }



    // 展开收缩
    function  tree_open(obj)
    {
        var tree = $('#list-table tr[id^="2_"], #list-table tr[id^="3_"] '); //,'table-row'
        if(tree.css('display')  == 'table-row')
        {
            $(obj).html("<i class='fa fa-angle-double-down'></i>展开");
            tree.css('display','none');
            $("span[id^='icon_']").removeClass('glyphicon-minus');
            $("span[id^='icon_']").addClass('glyphicon-plus');
        }else
        {
            $(obj).html("<i class='fa fa-angle-double-up'></i>收缩");
            tree.css('display','table-row');
            $("span[id^='icon_']").addClass('glyphicon-minus');
            $("span[id^='icon_']").removeClass('glyphicon-plus');
        }
    }

    // 以下是 bootstrap 自带的  js
    function rowClicked(obj)
    {
        span = obj;

        obj = obj.parentNode.parentNode;

        var tbl = document.getElementById("list-table");

        var lvl = parseInt(obj.className);

        var fnd = false;

        var sub_display = $(span).hasClass('glyphicon-minus') ? 'none' : '' ? 'block' : 'table-row' ;
        //console.log(sub_display);
        if(sub_display == 'none'){
            $(span).removeClass('glyphicon-minus btn-info');
            $(span).addClass('glyphicon-plus btn-warning');
        }else{
            $(span).removeClass('glyphicon-plus btn-info');
            $(span).addClass('glyphicon-minus btn-warning');
        }

        for (i = 0; i < tbl.rows.length; i++)
        {
            var row = tbl.rows[i];

            if (row == obj)
            {
                fnd = true;
            }
            else
            {
                if (fnd == true)
                {
                    var cur = parseInt(row.className);
                    var icon = 'icon_' + row.id;
                    if (cur > lvl)
                    {
                        row.style.display = sub_display;
                        if (sub_display != 'none')
                        {
                            var iconimg = document.getElementById(icon);
                            $(iconimg).removeClass('glyphicon-plus btn-info');
                            $(iconimg).addClass('glyphicon-minus btn-warning');
                        }else{
                            $(iconimg).removeClass('glyphicon-minus btn-info');
                            $(iconimg).addClass('glyphicon-plus btn-warning');
                        }
                    }
                    else
                    {
                        fnd = false;
                        break;
                    }
                }
            }
        }

        for (i = 0; i < obj.cells[0].childNodes.length; i++)
        {
            var imgObj = obj.cells[0].childNodes[i];
            if (imgObj.tagName == "IMG")
            {
                if($(imgObj).hasClass('glyphicon-plus btn-info')){
                    $(imgObj).removeClass('glyphicon-plus btn-info');
                    $(imgObj).addClass('glyphicon-minus btn-warning');
                }else{
                    $(imgObj).removeClass('glyphicon-minus btn-warning');
                    $(imgObj).addClass('glyphicon-plus btn-info');
                }
            }
        }

    }
</script>
</body>
</html>


